# -*- coding: utf-8 -*-
# @Create_time   :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :.py
# @Desc          : 每日统计扫描数据量 小时VS天
from jms.ods import jms_ods__yl_oms_oms_waybill
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from datetime import timedelta
from jms.time_sensor.time_after_01_30 import time_after_01_30

jms_data_check__jms_barscan_day_vs_hour_check_dt = SparkSqlOperator(
    task_id='jms_data_check__jms_barscan_day_vs_hour_check_dt',
    task_concurrency=1,
    pool_slots=4,
    master='yarn',
    name='jms_data_check__jms_barscan_day_vs_hour_check_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/datacheck/jms/jms_barscan_d_vs_h_check/execute.sql',
    email=['lukunming@jtexpress.com','yl_bigdata@yl-scm.com'],
    executor_cores=2 , 
    executor_memory='1G' , 
    num_executors=2 , 
    conf={'spark.dynamicAllocation.enabled'                  : 'true',  # 动态资源开启
          'spark.shuffle.service.enabled'                    : 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode'         : 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '1G' , 
          'spark.sql.shuffle.partitions'                     : 200,
          },
    hiveconf={
        'hive.exec.dynamic.partition' : 'true',  # 动态分区
        'hive.exec.dynamic.partition.mode' : 'nonstrict',
        'hive.exec.max.dynamic.partitions' : 400,  # 每天生成 20 个分区
        'hive.exec.max.dynamic.partitions.pernode': 400,  # 每天生成 20 个分区
    },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=20),
)

jms_data_check__jms_barscan_day_vs_hour_check_dt << time_after_01_30

